package com.qs.questionnairesurveysystem.service.impl;

import com.qs.questionnairesurveysystem.entity.Survey;
import com.qs.questionnairesurveysystem.mapper.SurveyMapper;
import com.qs.questionnairesurveysystem.service.SurveyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SurveyServiceImpl implements SurveyService {

    @Autowired
    private SurveyMapper surveyMapper;

    // 创建新问卷
    @Override
    public void createSurvey(Survey survey) {
        surveyMapper.insertSurvey(survey);
    }

    // 更新问卷
    @Override
    public void updateSurvey(Survey survey) {
        surveyMapper.updateSurvey(survey);
    }

    // 删除问卷
    @Override
    public void deleteSurvey(Long surveyId) {
        surveyMapper.deleteSurvey(surveyId);
    }

    // 获取指定问卷
    @Override
    public Survey getSurveyById(Long surveyId) {
        return surveyMapper.getSurveyById(surveyId);
    }

    // 获取所有问卷
    @Override
    public List<Survey> getAllSurveys() {
        return surveyMapper.getAllSurveys();
    }

    // 根据创建者ID获取问卷
    @Override
    public List<Survey> getSurveysByCreatorId(Long creatorId) {
        return surveyMapper.getSurveysByCreatorId(creatorId);
    }

    @Override
    public List<Survey> getEndSurveys() {
        return surveyMapper.getEndSurveys();
    }

    @Override
    public List<Survey> getEndSurveysRecord(Long uid) {
        return surveyMapper.getEndSurveysRecord(uid);
    }
}
